package study.day7;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

public class T4 {
    //字符流读取文件
    public static void main(String[] args) {
        FileReader fr = null;
        StringBuffer sb = new StringBuffer();
        try {
            fr=new FileReader("C:\\Users\\DELL\\IdeaProjects\\file\\2.txt");
            char[] chars=new char[1024];
            int length = fr.read(chars);
            sb=new StringBuffer();
            while (length!=-1){
                sb.append(chars, 0, length);
                length=fr.read(chars);
            }
        } catch (FileNotFoundException e) {
            System.out.println("file not found");
        }catch (IOException e){
            e.printStackTrace();
        }
        System.out.println(sb);
    }
}
